<!DOCTYPE html> 
<html lang="en-US">
  <head>
  
    <meta charset="UTF-8">
	<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
	<title>Prime-School Admin Login</title>
	
	
	<script src="<?php echo base_url(); ?>assets/js/jquery-2.0.3.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/encryption/extended5.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/encryption/fouriermultiply1.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/encryption/rsa2.js"></script>
    
  
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/todc-bootstrap.min.css">
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/style.css">
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/custom_style.css">
	<link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/theme/color_1.css" id="theme">
	<link href='http://fonts.googleapis.com/css?family=Roboto:300&amp;subset=latin,latin-ext' rel='stylesheet' type='text/css'>
	<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
	<style>
		body {padding:80px 0 0}
		textarea, input[type="password"], input[type="text"], input[type="submit"] {-webkit-appearance: none}
		.navbar-brand {font:300 15px/18px 'Roboto', sans-serif}
		.login_wrapper {position:relative;width:380px;margin:0 auto}
		.login_panel {background:#f8f8f8;padding:20px;-webkit-box-shadow: 0 0 0 4px #ededed;-moz-box-shadow: 0 0 0 4px #ededed;box-shadow: 0 0 0 4px #ededed;border:1px solid #ddd;position:relative}
		.login_head {margin-bottom:20px}
		.login_head h1 {margin:0;font:300 20px/24px 'Roboto', sans-serif}
		.login_submit {padding:10px 0}
		.login_panel label a {font-size:11px;margin-right:4px}
		
		@media (max-width: 767px) {
			body {padding-top:40px}
			.navbar {display:none}
			.login_wrapper {width:100%;padding:0 20px}
		}
	</style>
	<!--[if lt IE 9]>
		<script src="js/ie/html5shiv.js"></script>
		<script src="js/ie/respond.min.js"></script>
	<![endif]-->
</head>
  <body>
	 <header class="navbar navbar-default navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand" href="http://www.techno-bd.com">www.techno-bd.com</a>
			</div>
			<div class="pull-right">
				<ul class="nav navbar-nav">
					<li class="active"><a href="index.php" >School Management Software</a></li>
				</ul>
			</div>
		</div>
    </header>
    <div class="login_wrapper">
	 
	 <div class="login_panel log_section">
			<div class="login_head">
				<h1 align="center">Log In to Prime-School</h1>
			</div>
			<form action="<?php echo base_url(); ?>index.php?/admin/login/validate_credentials" method="post" accept-charset="utf-8" class="form-signin" id="login_form" autocomplete="off">
				<div class="form-group">
					<label for="login_username">Username</label>
					<input type="text" id="user_name" name="user_name" class="form-control input-lg" data-required="true" data-minlength="2" data-required-message="Please enter a valid Username" value="" >
				</div>
				<div class="form-group">
					<label for="login_password">Password </label>
					<input type="password" id="password" name="password" class="form-control input-lg" data-required="true" data-minlength="6" data-minlength-message="Password should have at least 6 characters." data-required-message="Please enter a valid Password" value="">
                     <input type="hidden" name="h_password" id="h_password" value="">
                    <label > <a href="#" class="pull-right">Forgot password?</a></label>
                    <input type="hidden" value="" name="login-attempt" id="login-attempt" />
                    <div class="error_message" >  </div>
					<!--<label class="checkbox"><input type="checkbox" name="login_remember" id="login_remember"> Remember me</label>-->
				</div>
				<div class="login_submit">
					<button class="btn btn-primary btn-block btn-lg" name="login_submit"  id="loadRSA">Log In</button>
				</div>
				<div class="text-center">
					
				</div>
			</form>
		</div>
	 
	 </div>
	 
	<script src="<?php echo base_url(); ?>js/jquery.min.js"></script>
	<!-- jquery cookie -->
			<script src="<?php echo base_url(); ?>js/jquery_cookie.min.js"></script>
	<script src="<?php echo base_url(); ?>js/lib/parsley/parsley.min.js"></script>
	<script>
	
	</script> 
	 
    
    
    

		
  <script type="text/javascript">  
  $("#loadRSA").click(function(event){  
      event.preventDefault();
      loadKey();
     // $('#form1').submit();
   });
  ////////////////////
  function isEnterKey(KEYCODE,OBJECT)
  {
   if(KEYCODE==13)
   {
     loadKey();
   }
  }
////////////////
  function loadKey()
   {
		var request=$.ajax({
	        type: 'POST',
	        url: '<?php echo base_url(); ?>index.php?/cycret/getKeys',
	        //data: $(this).serialize(),
	        data: "password=",
	        dataType: 'html'
	       });

		request.done(function(data) {
			   if(data!="")
			   {
		 	     ReceivedData= data.split("/"); 
		 	     key=ReceivedData[0];
		 	     mod=ReceivedData[1];
		 	     message=document.getElementById('password').value;
			     encode=rsa_encrypt(message,key,mod);
			     document.getElementById('password').value="";
			     document.getElementById('h_password').value=encode;
			     $('#login_form').submit();
			     //document.getElementById("form1").submit();
			   }
		});
		
		request.fail(function(jqXHR, textStatus) {
		    alert( "Request failed: " + textStatus );
		});
		
   }//End loadKey function

 ////////////////////////////////////////////////
  function  loadKey2()
      {
	  var xhr;
	    if (window.XMLHttpRequest) {
	        xhr = new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject) {
	        xhr = new ActiveXObject("Msxml2.XMLHTTP");
	    }
	    else {
	        throw new Error("Ajax is not supported by this browser");
	    }
	    xhr.onreadystatechange = function () {
	        if (xhr.readyState === 4) {
	            if (xhr.status == 200 && xhr.status < 300) {
	                alert(xhr.responseText);
	            }
	        }
	    }
	    //var url= '<?php echo base_url(); ?>index.php?/cycret/getKeys';
	    var url= "http://www.techno-bd.com/onlineresult/index.php?/cycret/getKeys";
	    xhr.open('POST', url);
	    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	    xhr.send();

	  }
//////////RSA Encryption Start////////////////

  function rsa_encrypt(m,  e,  n) { 
	    var asci = new Array; 
	    for (i=0; i<m.length; i+=3) { 
	        var tmpasci="1"; 
	        for (h=0; h<3; h++) { 
	            if (i+h <m.length) { 
		            st=m.substring(i+h,  i+h+1);
	                tmpstr = st.charCodeAt (0) - 30; 

	                if (tmpstr.length < 2) { 
	                   tmpstr ="0"+tmpstr; 
	                } 
	            } else { 
	                break; 
	            } 
	            tmpasci +=tmpstr; 
	        } 
	        asci.push(tmpasci+"1"); 
	    } 

	    //Encrypt individual numbers 
	    coded = "";
	    for (k=0; k< asci.length; k++) { 
	        resultmod = powmod(asci[k],  e,  n); 
	        coded += resultmod+" "; 
	    } 
		//encrypt function returns m = x^d (mod n) 
	    return coded.trim(); 
	} 

	//Exponentiation function
	function powmod(base,  exp,  modulus) { 
	    accum = 1; 
	    i = 0; 
	    basepow2 = base; 
	    while ((exp >> i)>0) { 
	        if (((exp >> i) & 1) == 1) { 
	            accum = mo((accum*basepow2),modulus); 
	        } 
	        basepow2 = mo((basepow2 * basepow2) ,  modulus); 
	        i++; 
	    } 
	    return accum; 
	}
  //////////////////////////
	function mo(g, l) { 
		return g - (l * Math.floor(g/l)); 
	} 
	////////////////////////////

  </script>
  </body>
</html>    
    